package leetcode.周赛.第273场;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2021/12/26 16:18
 * @description：https://leetcode-cn.com/contest/weekly-contest-273/problems/recover-the-original-array/
 */
public class 还原原数组 {
    @Test
    public void test() {
        Solution solution = new Solution();
        System.out.println(Arrays.toString(solution.recoverArray(new int[]{11,6,3,4,8,7,8,7,9,8,9,10,10,2,1,9})));
    }

    class Solution {
        public int[] recoverArray(int[] nums) {
            Arrays.sort(nums);
            int n = nums.length / 2;
            int k = (nums[n] - nums[0]) / 2;
            int[] ans = new int[n];
            for (int i = 0; i < n; i++) {
                ans[i] = nums[i] + k;
            }
            return ans;
        }
    }
}